Re: [SQL] Date - Mailing list pgsql-sql

From Herouth Maoz
Subject Re: [SQL] Date
Date
Msg-id l03110706b1c8f014f080@[147.233.159.109]
Whole thread Raw
In response to Date  (Chairudin Sentosa Harjo <tsg@dnet.net.id>)
List pgsql-sql
At 12:10 +0300 on 8/7/98, Chairudin Sentosa Harjo wrote:


> I need help with date.
>
> create table blah
> (
>   custnum int,
>    startdate date,
>    enddate date
> );
>
> How do I get the "real date" to insert to startdate when
> the data is entered?
>
> insert into blah
> (custnum, startdate, enddate)
> values
> (001,???,'NULL');
>
> I need a way to fill in the '???' field.
> In oracle I could use
> select sysdate from dual;

First, I recommend that you use datetime, not date. Date is a limited type,
and has less options.

That said, you can use either:

insert into blah
(custnum, startdate, enddate)
values
(001, 'now', null);

Or

values
(001, current_date, null);

See the manpage "pgbuiltin".

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma



pgsql-sql by date:

Previous
From: Chairudin Sentosa Harjo
Date:
Subject: Date
Next
From: "Stephen Horton"
Date:
Subject: Newby Postgres questions